
<?php
define('ROOT', dirname(SYSTEM_ROOT) . '/');

include ROOT."app/common.php";

$param = $_REQUEST['buy'];
if(!isset($param)){
    echo "该广告位暂时处于保护状态";exit;
}
$str = _decrypt($param,SYS_KEY);

$arr = explode("|||",$str);//加密时的分割线
$adArr = ['big','small','word'];//数据表 数组
if(count($arr) < 2 || !in_array(trim($arr[1]),$adArr)){
     echo "该广告位暂时处于保护状态";exit;
}

$id = trim($arr[0]);//编号
$data = trim($arr[1]);//数据表后缀
$today = date("Y-m-d");//当天时间

$bigAd = $ADDB->query("SELECT * FROM ad_{$data} where id = {$id}  limit 1")->fetch();
if(empty($bigAd) || $today < $bigAd['end_time']){
    echo "该广告位暂时处于保护状态";exit;
}
$title = getAdName($data);

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $config['site_name']?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="./component/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="./component/css/admin.css" media="all">
    <link rel="stylesheet" href="./component/css/login.css" media="all">
</head>
<style type="text/css">
    #LAY-user-login {
        width: 100%;
        height: 100%;
        background-size: 300%;
        animation: bganimation 30s infinite;
        font-family: '@font-face';
    }
    @font-face {
        font-family: 'Nunito';
        font-style: normal;
        font-weight: 400;
        unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
    }

    .FontColor {
        background-image: -webkit-linear-gradient(125deg, #29b9ff, #ff5b40);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        text-align: center;
        font-size: 2em;
        height: 3em;
        line-height: 3em;
        color: #745dff;
    }
    .LoginIcon {color: coral;cursor: pointer;}
    .LgoinBtn {background: #76e633;}
    .LgoinBtnDe {background: #CCCCCC;}
    .visitor {width: 2em;height: 2em;margin: 0em auto;box-shadow: 3px 3px 8px 0px #ccc;border-radius: 30rem;cursor: pointer;margin-top: 0em;}
</style>
<body>
<style>
    @media screen and (max-width: 788px) {
        .nbi {
            width: 94% !important;
            margin-top: -3.5em;
        }
    }
</style>

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;width: 100%;height: auto;background-image: url(https://bing.ioliu.cn/v1/rand?w=1920&h=1080);-webkit-background-size: cover和-o-background-size: cover;">
    <div class="layadmin-user-login-main nbi" style="background-color: white;border-radius: 0.3em;opacity: 0.9;">
        <div class="layadmin-user-login-box layadmin-user-login-header" style="margin-top: -10px">
            <h2 class="FontColor"><?php echo $title;?>购买</h2>
            <h5>价格：<?php echo $bigAd['price']?>元/月</h5>
            <p>[广告位置<?php echo $bigAd['sort']?>]</p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form" style="margin-top: 10px">
            <div class="layui-form-item">
                <input type="text" name="ad_qq" placeholder="请填写联系QQ" lay-verType="tips"  class="layui-input" lay-verify="required" style="width: 100%;"/>
            </div>
            <div class="layui-form-item">
                <input type="text" name="ad_url" placeholder="请填写广告链接,带http" lay-verType="tips" class="layui-input" lay-verify="required" style="width: 100%;"/>
            </div>
            <input type="hidden" name="id" value="<?php echo $id;?>"/>
            <input type="hidden" name="ad_type" value="<?php echo $data;?>"/>

            <?php if($data == 'word'){//文字广告
                echo '<div class="layui-form-item">
                        <input type="text" name="ad_title" placeholder="请填写广告标题"  lay-verType="tips" class="layui-input" style="width: 100%;"/>
                    </div>
                    ';
            } else{
                echo '<div class="layui-form-item">
                        <input type="text" name="ad_img" placeholder="请输入图片地址,带http" lay-verType="tips" class="layui-input" style="width: 100%;"/>
                    </div>';
            } ?>


            <div class="layui-form-item">
                <select  class="layui-input" name="month" style="width: 100%;">
                    <option value="" >选择购买时间</option>
                    <option value="1" >购买1个月</option>
                    <option value="2" >购买2个月</option>
                    <option value="3" >购买3个月</option>
                    <option value="4" >购买4个月</option>
                    <option value="5" >购买5个月</option>
                    <option value="6" >购买6个月</option>
                </select>
            </div>

            <div class="layui-form-item">
                <select  class="layui-input" name="payType" style="width: 100%;">
                    <option value="" >选择支付方式</option>
                    <option value="alipay" >支付宝支付</option>
                    <option value="wxpay" >微信支付</option>
                </select>
            </div>


            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode"></label>
                        <input type="text" name="code" id="code" lay-verify="required"   placeholder="图片验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img id="codeimg" src="./code.php?r=1646282024" height="38" onclick="this.src='./code.php?r='+Math.random();" title="点击更换验证码" class="layadmin-user-login-codeimg">
                        </div>
                    </div>
                </div>
            </div>

            <br/>
            <div class="layui-form-item" style="margin-bottom: 20px;">
<!--                <input type="checkbox" name="remember" lay-skin="primary" checked="checked" onclick="authdesc();" title="服务协议">
-->                <a onclick="authdesc();" href="#" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">广告说明</a>
            </div>
            <button class="layui-btn layui-btn-fluid layui-anim layui-anim-upbit" id="submit_login" style="background-color: #ff7235" lay-submit lay-filter="pay">立即支付</button>
            <a href="/" class="layui-trans layui-form-item layadmin-user-login-other"><label>返回首页</label>
            </a>
        </div>
    </div>
    <div class="layui-trans layadmin-user-login-footer" style="color: white;">
        <p>© 2022 <a href="/" target="_blank" style="color: white;"><?php echo $config['site_name']?></a></p>
    </div>
</div>
<script src="//lib.baomitu.com/jquery/3.4.1/jquery.min.js"></script>
<script src="//lib.baomitu.com/layer/2.3/layer.js"></script>
<script src="./component/layui/layui.js"></script>
<script>

    var $_GET = (function(){
        var url = window.document.location.href.toString();
        var u = url.split("?");
        if(typeof(u[1]) == "string"){
            u = u[1].split("&");
            var get = {};
            for(var i in u){
                var j = u[i].split("=");
                get[j[0]] = j[1];
            }
            return get;
        } else {
            return {};
        }
    })();


    function authdesc() {
        layer.open({
            title: "广告说明",
            content: '1.价格我们是按网站流量稳定性来定，希望理解' +
                '</br>2.广告不提供试用，以一个月为单位起购买' +
                '</br>3.如站长在到期之前询问是否续费的，请尽快回复，</br> &nbsp;&nbsp;&nbsp;48小时内若不回复，我们有权提前下掉广告' +
                '</br>4.从广告收款起，中途本站不接受任何理由的退款！' +
                '</br>5.不接黄赌毒类、代刷类、影视类广告 '+
                '</br>6.不接任何违法违规广告,如发现直接删除广告,不予退款! ',
            skin: 'layui-layer-admin',
            btnAlign: 'c',
            btn: '好的',
            icon: 1,
            type: 1
        })
    }


</script>

<script>
    layui.use(['form',  'jquery'], function() {
        var form = layui.form;
        let $ = layui.jquery;

        // 登 录 提 交
        form.on('submit(pay)', function(data) {
            var index = layer.msg('数据加载中', {time: 9999999});
            $.ajax({
                type: "post",
                url: "auth.php?act=pay",
                dataType: "json",
                data: JSON.stringify(data.field),
                contentType: 'application/json',
                success: function (res) {
                    layer.close(index);
                    if (res.code == 1) {
                        var data = res.data;
                        layer.msg(res.msg, {icon: 1, time: 1000, shade: 0.4}, function () {
                            window.location.href = './pay/submit.php?type=' + data.type + '&orderid=' + data.order_no;
                        });
                    } else {
                        layer.msg(res.msg, {icon: 7, time: 2000, shade: 0.4});
                    }
                },
                error: function () {
                    layer.alert('服务器异常！');
                    layer.close(index);
                }
            });
            return false;
        });
    })
</script>

</body>
</html>